<template>
  <div class="consumer_machine">
    <el-row>
      <dragdrop :width="0" :widthLeft="'170px'">
        <template slot="left">
          <div class="left_shuju">
            <div class="grid-content bg-purple">
              <div class="header_title">
                <span>模板数据</span>
              </div>
              <div class="addtemplate" v-if="isauth('consume_p_edit')">
                <el-button
                  title="新增"
                  type="primary"
                  size="mini"
                  @click="addtForm"
                  icon="el-icon-plus"
                >新增模板</el-button>
              </div>
              <el-table
                :data="tableData"
                border
                @row-click="rowClick"
                highlight-current-row
                :header-cell-style="headFirst"
                :height="'calc(100vh - 220px)'"
              >
                <el-table-column align="center" prop="templateName" label="模板名称"></el-table-column>
                <el-table-column
                  label="操作"
                  align="center"
                  v-if="isauth('consume_p_edit')"
                  width="80px"
                >
                  <template slot-scope="scope">
                    <el-button type="text" size="small" @click.stop="eidtDate(scope.row)">修改密码</el-button>
                    <el-button
                      v-if="userType === '1' || userType == '50' ? true : false"
                      type="text"
                      size="small"
                      @click.stop="resetDate(scope.row)"
                    >重置密码</el-button>
                    <el-button
                      type="text"
                      size="small"
                      style="color:red"
                      @click.stop="deleteDate(scope.row)"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </template>
        <template slot="right">
          <div class="right_shuju">
            <div class="grid-content bg-purple-light" v-if="isShow">
              <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="基础参数" name="third">
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    :inline="true"
                    style="marginTop:20px"
                  >
                    <el-form-item label="名单类型:" class="el_form_label_width">
                      <el-radio-group v-model="rosterType">
                        <el-radio :label="1">白名单</el-radio>
                        <el-radio :label="0">黑名单</el-radio>
                      </el-radio-group>
                    </el-form-item>
                    <el-form-item label="设备配置密码/退款码:" label-width="160px">
                      <el-input
                        placeholder="请输入密码"
                        v-model="terminalOperationPassword"
                        show-password
                        style="width:120px"
                        maxlength="4"
                        oninput="value=value.replace(/[^\d]/g,'')"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="管理卡号:" label-width="90px">
                      <el-input
                        v-model="manageNumber"
                        placeholder="管理卡号"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        style="width:120px"
                        maxlength="10"
                      ></el-input>
                    </el-form-item>
                  </el-form>
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    :inline="true"
                  >
                    <el-form-item label="刷卡时段检查" label-width="90px">
                      <el-col :span="24">
                        <el-select
                          v-model="creditCardTimeSpaceExamine"
                          placeholder="请选择"
                          size="mini"
                          style="width:100px"
                        >
                          <el-option
                            v-for="item in iscreditCardTimeSpaceExamine"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          ></el-option>
                        </el-select>
                      </el-col>
                    </el-form-item>
                    <el-form-item label="返回待机界面时间:" label-width="122px">
                      <el-col :span="20">
                        <el-input-number
                          v-model="returnWaitInterfaceTime"
                          :min="0"
                          :max="250"
                          style="width:120px"
                        ></el-input-number>
                      </el-col>
                      <el-col :span="2" :offset="2">秒</el-col>
                      <!-- <el-input
                        v-model="returnWaitInterfaceTime"
                        placeholder="0-250"
                        style="width:100px"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        maxlength="3"
                        :max="250"
                      >
                        <i slot="suffix" style="font-style:normal;margin-right: 10px;">秒</i>
                      </el-input>-->
                    </el-form-item>
                    <el-form-item label="消费模式:" label-width="70px">
                      <el-select
                        v-model="consumeModel"
                        placeholder="请选择"
                        size="mini"
                        style="width:100px"
                      >
                        <el-option
                          v-for="item in consumeModeloption"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="启用卡有效时间:" label-width="120px">
                      <el-checkbox v-model="cardTermValidityExamine"></el-checkbox>
                    </el-form-item>
                  </el-form>
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    :inline="true"
                  >
                    <el-form-item label="名单分区字节序号:" prop="rosterDistrictByteOrder">
                      <el-select
                        v-model="rosterDistrictByteOrder"
                        placeholder="请选择"
                        size="mini"
                        style="width: 80px"
                        disabled
                      >
                        <el-option
                          v-for="item in rosterDistrictByteOrderoption"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="刷卡自动延长有效期:" label-width="140px">
                      <el-checkbox v-model="autoAddCardPeriodValidity"></el-checkbox>
                    </el-form-item>
                  </el-form>
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    :inline="true"
                  >
                    <el-form-item label="无线模块重启计时:" label-width="130px">
                      <el-input-number
                        v-model="wirelessIdleRestartTiming"
                        :min="0"
                        :max="250"
                        label="0-250"
                      ></el-input-number>
                      <span style="color:red;marginLeft:5px">分 注:0标识不重启</span>
                    </el-form-item>

                    <!-- <el-form-item label="使用卡类型:" label-width="90px">
                    <el-select v-model="cardType" placeholder="请选择" size="mini" clearable>
                      <el-option v-for="item in cardTypeoption" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                    </el-form-item>-->
                    <el-form-item label="最大当次消费额:" label-width="120px">
                      <el-input-number
                        v-model="cardMaxConsumeAmountMoney"
                        :min="0"
                        :max="65535"
                        label="0-65535"
                      ></el-input-number>
                      <!-- <el-col :span="11">
                        <el-input
                          v-model="cardMaxConsumeAmountMoney"
                          placeholder="0-65535"
                          oninput="value=value.replace(/[^\d]/g,'')"
                        >
                          <i slot="suffix" style="font-style:normal;margin-right: 10px;">元</i>
                        </el-input>
                      </el-col>-->
                      <!-- <el-col :span="10"> -->
                      <span style="color:red;marginLeft:5px">注:0为不限制</span>
                      <!-- </el-col> -->
                    </el-form-item>
                  </el-form>
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    :inline="true"
                  >
                    <!-- <el-form-item label="允许卡内最大金额" label-width="121px"></el-form-item> -->
                    <el-form-item label="限制卡内余额大于" label-width="121px">
                      <el-input-number
                        v-model="cardMaxAmountMoney"
                        :min="0"
                        :max="65535"
                        label="0-65535"
                      ></el-input-number>
                      <!-- <el-col :span="11">
                        <el-input
                          v-model="cardMaxAmountMoney"
                          placeholder="0-65535"
                          oninput="value=value.replace(/[^\d]/g,'')"
                        >
                        </el-input>
                      </el-col>
                      <el-col :span="13">-->
                      <span style="color:red;marginLeft:5px">元时，不能消费。0为不限制</span>
                      <!-- </el-col> -->
                    </el-form-item>
                  </el-form>
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    :inline="true"
                  >
                    <!-- <el-form-item label="允许卡内最少金额" label-width="121px"></el-form-item>
                  <el-form-item label="限制卡内余额少于" label-width="121px">
                    <el-col :span="11">
                      <el-input v-model="securityEndConsumeAmountMoney" placeholder="0-255" oninput="value=value.replace(/[^\d]/g,'')">
                        <i slot="suffix" style="font-style:normal;margin-right: 10px;">分</i>
                      </el-input>
                    </el-col>
                    <el-col :span="11">
                      <span style="color:red;marginLeft:5px">元时，不能消费</span>
                    </el-col>
                    </el-form-item>-->
                  </el-form>
                </el-tab-pane>
                <el-tab-pane label="消费规则限制" name="first">
                  <div class="consumption_rules">
                    <el-form
                      :inline="true"
                      :model="elform"
                      class="demo-form-inline"
                      size="mini"
                      ref="elform"
                      :rules="elformRule"
                    >
                      <el-form-item label="消费超出限制规则时:" label-width="150px" prop="isOpenExcess">
                        <el-col :span="24">
                          <el-select
                            v-model="elform.isOpenExcess"
                            placeholder="请选择"
                            size="mini"
                            clearable
                          >
                            <el-option
                              v-for="item in isOpenExcessoption"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            ></el-option>
                          </el-select>
                        </el-col>
                      </el-form-item>
                      <el-form-item
                        label="同一张卡刷卡时间间隔:"
                        label-width="170px"
                        prop="creditCardSpaceTime"
                      >
                        <el-col :span="12">
                          <el-input
                            v-model="elform.creditCardSpaceTime"
                            size="mini"
                            clearable
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </el-col>
                        <el-col :span="12">
                          <span style="paddingLeft:8px">分钟(0为不限制)</span>
                        </el-col>
                      </el-form-item>
                    </el-form>
                    <div class="explanation">
                      <el-table
                        v-loading="loading"
                        :data="alldata.groupRestrictionDataList"
                        ref="table"
                        border
                        :header-cell-style="header =>headFirst(header, 3)"
                        style="width: 100%"
                        height="calc(100vh - 315px)"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column align="center" prop="isOpenAll" label="启用规则" min-width="60px">
                          <template slot-scope="scope">
                            <el-checkbox v-model="scope.row.isOpenAll"></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column align="center" prop="groupCode" label="消费角色" min-width="135px">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.groupCode" size="mini" disabled>
                              <el-option
                                v-for="item in grouplistdata"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                              ></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <el-table-column align="center" label="消 费 类 型 规 则">
                          <el-table-column
                            prop="restrictionPeriod"
                            align="center"
                            label="限制类型"
                            width="110px"
                          >
                            <template slot-scope="scope">
                              <el-select
                                v-model="scope.row.restrictionPeriod"
                                size="mini"
                                @change="restrictionPeriod"
                              >
                                <el-option
                                  v-for="item in mealrestrictionsoption"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value"
                                ></el-option>
                              </el-select>
                            </template>
                          </el-table-column>
                          <el-table-column align="center" label="早餐">
                            <el-table-column prop="isOpen_morning" align="center" label="启用限制" width="60px">
                              <template slot-scope="scope">
                                <el-checkbox
                                  v-model="scope.row.isOpen_morning"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                ></el-checkbox>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionAmount_morning"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getmoneymorning(
                                  scope.row.restrictionAmount_morning,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionAmount_morning"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber_morning"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getnumberlimtmorning(
                                  scope.row.restrictionNumber_morning,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionNumber_morning"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                          </el-table-column>
                          <el-table-column align="center" label="中餐">
                            <el-table-column prop="isOpen_lunch" align="center" label="启用限制" width="60px">
                              <template slot-scope="scope">
                                <el-checkbox
                                  v-model="scope.row.isOpen_lunch"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                ></el-checkbox>
                              </template>
                            </el-table-column>

                            <el-table-column
                              prop="restrictionAmount_lunch"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getmoneylunch(
                                  scope.row.restrictionAmount_lunch,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionAmount_lunch"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber_lunch"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getnumberlimtlunch(
                                  scope.row.restrictionNumber_lunch,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionNumber_lunch"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                          </el-table-column>
                          <el-table-column align="center" label="晚餐">
                            <el-table-column prop="isOpen_dinner" align="center" label="启用限制" width="60px">
                              <template slot-scope="scope">
                                <el-checkbox
                                  v-model="scope.row.isOpen_dinner"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                ></el-checkbox>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionAmount_dinner"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getmoneydinner(
                                  scope.row.restrictionAmount_dinner,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionAmount_dinner"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber_dinner"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getnumberlimtdinner(
                                  scope.row.restrictionNumber_dinner,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionNumber_dinner"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                          </el-table-column>
                          <el-table-column align="center" label="夜宵-A">
                            <el-table-column prop="isOpen_night" align="center" label="启用限制" width="60px">
                              <template slot-scope="scope">
                                <el-checkbox
                                  v-model="scope.row.isOpen_night"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                ></el-checkbox>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionAmount_night"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getmoneynight(
                                  scope.row.restrictionAmount_night,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionAmount_night"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber_night"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getnumberlimtnight(
                                  scope.row.restrictionNumber_night,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionNumber_night"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                          </el-table-column>
                          <el-table-column align="center" label="夜宵-B">
                            <el-table-column prop="isOpen_extra" align="center" label="启用限制" width="60px">
                              <template slot-scope="scope">
                                <el-checkbox
                                  v-model="scope.row.isOpen_extra"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                ></el-checkbox>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionAmount_extra"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                              getmoneyextra(
                                scope.row.restrictionAmount_extra,
                                scope.$index
                              )
                            "
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  v-model="scope.row.restrictionAmount_extra"
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber_extra"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                              getnumberlimtextra(
                                scope.row.restrictionNumber_extra,
                                scope.$index
                              )
                            "
                                  v-model="scope.row.restrictionNumber_extra"
                                  :disabled="
                                scope.row.restrictionPeriod == 1 ? false : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <!-- <el-table-column
                            align="center"
                            prop="cardStorageSite_extra"
                            label="汇总规则分组"
                            width="120"
                          >
                            <template slot-scope="scope">
                              <el-select
                                v-model="scope.row.cardStorageSite_extra"
                                size="mini"
                                @change="selectextraSite(scope.row, scope.$index)"
                              >
                                <el-option
                                  v-for="item in rulegroupingoption"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value"
                                ></el-option>
                              </el-select>
                            </template>
                            </el-table-column>-->
                          </el-table-column>
                          <el-table-column align="center" label="日周月限制规则">
                            <el-table-column
                              prop="restrictionAmount"
                              align="center"
                              label="限制金额(分)"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getmoneyAmount(
                                  scope.row.restrictionAmount,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionAmount"
                                  :disabled="
                                scope.row.restrictionPeriod != 1 &&
                                scope.row.restrictionPeriod != 0 && 
                                scope.row.restrictionPeriod != 5
                                  ? false
                                  : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                            <el-table-column
                              prop="restrictionNumber"
                              align="center"
                              label="限制次数"
                              width="100"
                            >
                              <template slot-scope="scope">
                                <el-input
                                  size="mini"
                                  @blur="
                                getnumberlimtNumbe(
                                  scope.row.restrictionNumber,
                                  scope.$index
                                )
                              "
                                  v-model="scope.row.restrictionNumber"
                                  :disabled="
                                scope.row.restrictionPeriod != 1 &&
                                scope.row.restrictionPeriod != 0&& 
                                scope.row.restrictionPeriod != 5
                                  ? false
                                  : true
                              "
                                  oninput="value=value.replace(/[^\d]/g,'')"
                                ></el-input>
                              </template>
                            </el-table-column>
                          </el-table-column>
                          <el-table-column
                            align="center"
                            prop="cardStorageSiteAll"
                            label="时段规则分组"
                            width="100px"
                          >
                            <template slot-scope="scope">
                              <el-select
                                v-model="scope.row.cardStorageSiteAll"
                                size="mini"
                                @change="selectcardsiteall(scope.row, scope.$index)"
                                :disabled="scope.row.restrictionPeriod == 5"
                              >
                                <el-option
                                  v-for="item in rulegroupingoption"
                                  :key="item.value"
                                  :label="item.label"
                                  :value="item.value"
                                ></el-option>
                              </el-select>
                            </template>
                          </el-table-column>
                        </el-table-column>
                      </el-table>
                    </div>
                  </div>
                </el-tab-pane>
                <el-tab-pane label="时段定额" name="second">
                  <el-form
                    :model="elform2"
                    class="demo-form-inline"
                    size="mini"
                    ref="elform2"
                    label-width="70px"
                    v-if="alldata.timeFrameDataList"
                  >
                    <el-row>
                      <el-col :span="8" style="marginTop:5px">
                        <el-form-item label="早餐:" class="el_form_label_width">
                          <el-col :span="10">
                            <el-time-picker
                              arrow-control
                              @change="selectime()"
                              v-model="alldata.timeFrameDataList[0].starttime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="shi_jian_zhi">至</el-col>
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[0].endTime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="xuan_zhe">
                            <el-checkbox
                              v-model="alldata.timeFrameDataList[0].validSign"
                              @change="checkusing"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4" style="marginTop:5px">
                        <el-form-item
                          label="是否自动扣费"
                          class="el_form_label_width"
                          label-width="120px"
                        >
                          <el-col :span="3" class="xuan_zhe">
                            <el-checkbox
                              style="marginLeft:10px"
                              v-model="alldata.timeFrameDataList[0].isAutoWithhold"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" style="marginTop:5px">
                        <el-form-item label="中餐:" class="el_form_label_width">
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[1].starttime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="shi_jian_zhi">至</el-col>
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[1].endTime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="xuan_zhe">
                            <el-checkbox v-model="alldata.timeFrameDataList[1].validSign"></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4" style="marginTop:5px">
                        <el-form-item
                          label="是否自动扣费"
                          class="el_form_label_width"
                          label-width="120px"
                        >
                          <el-col :span="3" class="xuan_zhe">
                            <el-checkbox
                              style="marginLeft:10px"
                              v-model="alldata.timeFrameDataList[1].isAutoWithhold"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" style="marginTop:5px">
                        <el-form-item label="晚餐:" class="el_form_label_width">
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[2].starttime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="shi_jian_zhi">至</el-col>
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[2].endTime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="xuan_zhe">
                            <el-checkbox v-model="alldata.timeFrameDataList[2].validSign"></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4" style="marginTop:5px">
                        <el-form-item
                          label="是否自动扣费"
                          class="el_form_label_width"
                          label-width="120px"
                        >
                          <el-col :span="3" class="xuan_zhe">
                            <el-checkbox
                              style="marginLeft:10px"
                              v-model="alldata.timeFrameDataList[2].isAutoWithhold"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" style="marginTop:5px">
                        <el-form-item label="夜宵A:" class="el_form_label_width">
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[3].starttime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="shi_jian_zhi">至</el-col>
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[3].endTime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="xuan_zhe">
                            <el-checkbox v-model="alldata.timeFrameDataList[3].validSign"></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4" style="marginTop:5px">
                        <el-form-item
                          label="是否自动扣费"
                          class="el_form_label_width"
                          label-width="120px"
                        >
                          <el-col :span="3" class="xuan_zhe">
                            <el-checkbox
                              style="marginLeft:10px"
                              v-model="alldata.timeFrameDataList[3].isAutoWithhold"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" style="marginTop:5px">
                        <el-form-item label="夜宵B:" class="el_form_label_width">
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[4].starttime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="shi_jian_zhi">至</el-col>
                          <el-col :span="10">
                            <el-time-picker
                              v-model="alldata.timeFrameDataList[4].endTime"
                              :picker-options="{
                            start: '00:00',
                            step: '00:01',
                            end: '23:59'
                          }"
                              value-format="HH:mm"
                              format="HH:mm"
                            ></el-time-picker>
                          </el-col>
                          <el-col :span="2" class="xuan_zhe">
                            <el-checkbox v-model="alldata.timeFrameDataList[4].validSign"></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4" style="marginTop:5px">
                        <el-form-item
                          label="是否自动扣费"
                          class="el_form_label_width"
                          label-width="120px"
                        >
                          <el-col :span="3" class="xuan_zhe">
                            <el-checkbox
                              style="marginLeft:10px"
                              v-model="alldata.timeFrameDataList[4].isAutoWithhold"
                            ></el-checkbox>
                          </el-col>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-form>
                  <el-table
                    :data="alldata.groupAmountDataList"
                    ref="table"
                    border
                    :header-cell-style="header =>headFirst(header, 2)"
                    style="width: 100%"
                    height="calc(100vh - 380px)"
                    :cell-style="(res) => headFirst_col(res, [], 2)"
                  >
                    <el-table-column align="center" prop="validSignAll" label="启用规则" width="60px">
                      <template slot-scope="scope">
                        <el-checkbox v-model="scope.row.validSignAll"></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column align="center" prop="groupCode" label="消费角色" width="140px">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.groupCode" size="mini" disabled>
                          <el-option
                            v-for="item in grouplistdata"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          ></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column align="center" label="早餐">
                      <el-table-column prop="validSignMorning" align="center" label="是否启用" width="60px">
                        <template slot-scope="scope">
                          <el-checkbox
                            v-model="scope.row.validSignMorning"
                            :disabled="
                          alldata.timeFrameDataList[0].validSign == true
                            ? false
                            : true
                        "
                          ></el-checkbox>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="groupAmount_morning"
                        align="center"
                        width="100"
                        label="定额金额(分)"
                      >
                        <template slot-scope="scope">
                          <el-input
                            size="mini"
                            v-model="scope.row.groupAmount_morning"
                            :disabled="
                          alldata.timeFrameDataList[0].validSign == true
                            ? false
                            : true
                        "
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </template>
                      </el-table-column>
                    </el-table-column>
                    <el-table-column align="center" label="中餐">
                      <el-table-column prop="validSignLunch" align="center" label="是否启用" width="60px">
                        <template slot-scope="scope">
                          <el-checkbox
                            v-model="scope.row.validSignLunch"
                            :disabled="
                          alldata.timeFrameDataList[1].validSign == true
                            ? false
                            : true
                        "
                          ></el-checkbox>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="groupAmount_lunch"
                        align="center"
                        width="100"
                        label="定额金额(分)"
                      >
                        <template slot-scope="scope">
                          <el-input
                            size="mini"
                            v-model="scope.row.groupAmount_lunch"
                            :disabled="
                          alldata.timeFrameDataList[1].validSign == true
                            ? false
                            : true
                        "
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </template>
                      </el-table-column>
                    </el-table-column>
                    <el-table-column align="center" label="晚餐">
                      <el-table-column
                        prop="validSignDinner"
                        align="center"
                        label="是否启用"
                        width="60px"
                      >
                        <template slot-scope="scope">
                          <el-checkbox
                            v-model="scope.row.validSignDinner"
                            :disabled="
                          alldata.timeFrameDataList[2].validSign == true
                            ? false
                            : true
                        "
                          ></el-checkbox>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="groupAmount_dinner"
                        align="center"
                        width="100"
                        label="定额金额(分)"
                      >
                        <template slot-scope="scope">
                          <el-input
                            size="mini"
                            v-model="scope.row.groupAmount_dinner"
                            :disabled="
                          alldata.timeFrameDataList[2].validSign == true
                            ? false
                            : true
                        "
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </template>
                      </el-table-column>
                    </el-table-column>
                    <el-table-column align="center" label="夜宵A">
                      <el-table-column prop="validSignNight" align="center" label="是否启用" width="60px">
                        <template slot-scope="scope">
                          <el-checkbox
                            v-model="scope.row.validSignNight"
                            :disabled="
                          alldata.timeFrameDataList[3].validSign == true
                            ? false
                            : true
                        "
                          ></el-checkbox>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="groupAmount_night"
                        align="center"
                        width="100"
                        label="定额金额(分)"
                      >
                        <template slot-scope="scope">
                          <el-input
                            size="mini"
                            v-model="scope.row.groupAmount_night"
                            :disabled="
                          alldata.timeFrameDataList[3].validSign == true
                            ? false
                            : true
                        "
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </template>
                      </el-table-column>
                    </el-table-column>
                    <el-table-column align="center" label="夜宵B">
                      <el-table-column
                        prop="validSignExtra"
                        align="center"
                        label="是否启用"
                        width="60px"
                      >
                        <template slot-scope="scope">
                          <el-checkbox
                            v-model="scope.row.validSignExtra"
                            :disabled="
                          alldata.timeFrameDataList[4].validSign == true
                            ? false
                            : true
                        "
                          ></el-checkbox>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="groupAmount_extra"
                        align="center"
                        width="100"
                        label="定额金额(分)"
                      >
                        <template slot-scope="scope">
                          <el-input
                            size="mini"
                            v-model="scope.row.groupAmount_extra"
                            :disabled="
                          alldata.timeFrameDataList[4].validSign == true
                            ? false
                            : true
                        "
                            oninput="value=value.replace(/[^\d]/g,'')"
                          ></el-input>
                        </template>
                      </el-table-column>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
              </el-tabs>
              <div class="footer" v-if="isauth('consume_p_edit')">
                <el-card class="box-card">
                  <div class="footerflex">
                    <div class="footer_save">
                      <el-input
                        size="mini"
                        v-model="alldatatemplatePassword"
                        show-password
                        placeholder="请输入密码"
                      ></el-input>
                    </div>
                    <div class="footer_save">
                      <el-button type="primary" size="mini" @click="savealldata">保存</el-button>
                    </div>
                    <div class="footer_save">
                      <!-- <el-button type="primary" size="mini" @click="onExport()">导出</el-button> -->
                    </div>
                    <div class="footer_parameter" style="padding: 0px 30px">
                      <span>把参数应用到...</span>
                      <el-select v-model="settlementunitGuid" placeholder="请选择" size="mini">
                        <el-option
                          v-for="item in settlementunitoption"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                      <el-button type="primary" size="mini" @click="applicationparameters">确定</el-button>
                    </div>
                    <div class="footer_merchant_equipment_parameters">
                      <el-button type="primary" size="mini" @click="savemerchant">重发参数模板</el-button>
                    </div>
                  </div>
                </el-card>
              </div>
            </div>
          </div>
        </template>
      </dragdrop>
    </el-row>
    <el-dialog
      :before-close="closeDialog"
      width="500px"
      center
      title="新增模板"
      :close-on-click-modal="false"
      :visible.sync="addDialogFormVisible"
    >
      <el-form :model="adddataForm" :rules="adddataRule" ref="adddataForm" label-width="80px">
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input v-model="adddataForm.templateName" placeholder="模板名称" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码"
              v-model="adddataForm.templatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addvisible()">取消</el-button>
        <el-button type="primary" @click="addFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :before-close="eidtcloseDialog"
      width="500px"
      center
      title="修改模板"
      :close-on-click-modal="false"
      :visible.sync="eidtDialogFormVisible"
    >
      <el-form :model="eidtdataForm" :rules="adddataRule" ref="eidtdataForm" label-width="90px">
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input v-model="eidtdataForm.templateName" placeholder="模板名称" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="新模板密码" prop="newPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="eidtdataForm.newPassword"
              show-password
              :disabled="changepassword===false?true:false"
              size="mini"
            ></el-input>
          </el-col>
          <el-col :span="5" style="paddingLeft:20px">
            <el-checkbox v-model="changepassword">是否修改密码</el-checkbox>
          </el-col>
        </el-form-item>
        <el-form-item label="原模板密码" prop="oldPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码,无则不填密"
              v-model="eidtdataForm.oldPassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="eidtvisible()">取消</el-button>
        <el-button type="primary" @click="eidtFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :before-close="resetcloseDialog"
      width="500px"
      center
      title="重置密码"
      :close-on-click-modal="false"
      :visible.sync="resetDialogFormVisible"
    >
      <el-form :model="resetdataForm" ref="resetdataForm" :rules="resetRule" label-width="110px">
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码"
              v-model="resetdataForm.templatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="确认模板密码" prop="confirmtemplatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="resetdataForm.confirmtemplatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetvisible()">取消</el-button>
        <el-button type="primary" @click="resetFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { JSEncrypt } from 'jsencrypt'
export default {
  data() {
    let checkcreditCardSpaceTime = (rule, value, callback) => {
      // /^(0|[1-9]\d*)(\.\d*)?$/
      let CardSpaceTime = /^(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))))$/
      if (!CardSpaceTime.test(value)) {
        callback(new Error('请输入正确的时间格式！(0-255)'))
      } else {
        callback()
      }
    }
    let resetPassword = (rule, value, callback) => {
      if (this.resetdataForm.templatePassword !== value) {
        callback(new Error('确认密码与新密码不一致'))
      } else {
        callback()
      }
    }
    return {
      isShow: false,
      /** 控制隐藏显示效果 */
      leftS: 5,
      rightS: 19,
      isrightS: false,
      isletfS: true,
      changepassword: false,
      alldatatemplatePassword: '',
      operatorGuid: '',
      userType: '',
      publicKey:
        'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx8wyZzYxaffWrJ4jooN554npe5vD2RSQGNXOY5UZz6hcIW0jdEk1KcdclE7mJPiI2DmgUjBp4Lau+bNmZxmLBqFHUMd29mWyqX+LuYVoymxs8f3VJF+7PqZzuKbtSOyXfcyjIIgtB06YlX4SXx4FCErGRx+MDseN2ObHSPme/3wIDAQAB',
      settlementunitGuid: '',
      settlementunitoption: [],
      searchInfo: {},

      buttonindex: '',
      activeName: '',
      tableData: [],
      templateGuid: '',
      elform: {},
      userName: '',
      adddataForm: {
        templateName: '',
        templatePassword: ''
      },
      eidtdataForm: {
        templateName: '',
        oldPassword: '',
        newPassword: '',
        templateGuid: ''
      },
      resetdataForm: {
        templatePassword: '',
        confirmtemplatePassword: '',
        templateGuid: ''
      },
      adddataRule: {
        templateName: [
          {
            required: true,
            message: '模板名称不能为空',
            trigger: 'blur'
          }
        ]
      },
      resetRule: {
        templatePassword: [
          {
            required: true,
            message: '模板密码不能为空',
            trigger: 'blur'
          }
        ],
        confirmtemplatePassword: [
          {
            required: true,
            message: '确认模板密码不能为空',
            trigger: 'blur'
          },
          {
            validator: resetPassword,
            trigger: 'blur'
          }
        ]
      },
      addDialogFormVisible: false,
      eidtDialogFormVisible: false,
      resetDialogFormVisible: false,
      loading: false,
      // 名单分区字节序号
      rosterDistrictByteOrder: '',
      /**无线空闲重启计时*/
      wirelessIdleRestartTiming: '',
      rosterDistrictByteOrderoption: [
        {
          label: '0',
          value: 0
        },
        {
          label: '1',
          value: 1
        },
        {
          label: '2',
          value: 2
        },
        {
          label: '3',
          value: 3
        }
      ],
      //消费规则限制参数

      elform: {
        //消费超出限制规则时
        isOpenExcess: '',
        //同一张卡时间间隔
        creditCardSpaceTime: ''
      },
      //消费超出限制规则时数据
      isOpenExcessoption: [
        {
          label: '不启用',
          value: 0
        },
        {
          label: '启用超额',
          value: 1
        },
        {
          label: '超额时自动采用定值金额2',
          value: 2
        }
      ],
      //消费模式
      consumeModeloption: [
        {
          label: '计次消费',
          value: 0
        },
        {
          label: '金额消费',
          value: 1
        }
      ],
      //卡类型
      cardTypeoption: [
        {
          label: 'IC卡',
          value: 0
        },
        {
          label: 'cpu卡',
          value: 1
        }
      ],
      elformRule: {
        creditCardSpaceTime: [
          {
            required: true,
            validator: checkcreditCardSpaceTime,
            trigger: 'blur'
          }
        ]
      },
      // 模板数据
      alldata: [],
      //消费限制表格数据
      groupRestrictionDataList: [],
      //时段定额表格数据
      groupAmountDataList: [],
      //分组资料数据
      grouplistdata: [],
      //餐别限制方式
      mealrestrictionsoption: [
        {
          label: '无限制',
          value: 0
        },
        {
          label: '限餐',
          value: 1
        },
        {
          label: '按日限制',
          value: 2
        },
        {
          label: '按周限制',
          value: 3
        },
        {
          label: '按月限制',
          value: 4
        },
        {
          label: '禁止消费',
          value: 5
        }
      ],
      //汇总餐别限制
      extramealrestrictionsoption: [
        {
          label: '无限制',
          value: 0
        },
        {
          label: '按日限制',
          value: 2
        },
        {
          label: '按周限制',
          value: 3
        },
        {
          label: '按月限制',
          value: 4
        }
      ],
      //规则分组
      rulegroupingoption: [
        {
          label: '1',
          value: 1
        },
        {
          label: '2',
          value: 2
        },
        {
          label: '3',
          value: 3
        }
      ],

      //时段定额
      elform2: {},
      value1: '',
      timevalue1: '',
      timevalue2: '',
      timeFrameDataList: [
        {
          validSign: false,
          endHour: 0,
          endMinute: 0,
          stateHour: 0,
          stateMinute: 0
        },
        {
          validSign: false,
          endHour: 0,
          endMinute: 0,
          stateHour: 0,
          stateMinute: 0
        },
        {
          validSign: false,
          endHour: 0,
          endMinute: 0,
          stateHour: 0,
          stateMinute: 0
        },
        {
          validSign: false,
          endHour: 0,
          endMinute: 0,
          stateHour: 0,
          stateMinute: 0
        },
        {
          validSign: false,
          endHour: 0,
          endMinute: 0,
          stateHour: 0,
          stateMinute: 0
        }
      ],
      radio: '1',
      timevalue: '',

      //时间段

      // 表单数据
      rosterType: '',
      terminalOperationPassword: '',
      manageNumber: '',
      returnWaitInterfaceTime: '',
      consumeModel: '',
      cardTermValidityExamine: false,
      autoAddCardPeriodValidity: false,
      cardType: '',
      cardMaxConsumeAmountMoney: '',
      cardMaxAmountMoney: '',
      securityEndConsumeAmountMoney: '',
      // 刷卡时段检查
      creditCardTimeSpaceExamine: '',

      iscreditCardTimeSpaceExamine: [
        {
          label: '禁止检查',
          value: 0
        },
        {
          label: '检查启动',
          value: 1
        }
      ],
      //判断选择模板
      temeplatecheck: false,
      exoprtlist: [],
      filename: '消费规则'
    }
  },
  created() {
    this.operatorGuid = sessionStorage.getItem('administrator')
    this.userType = sessionStorage.getItem('userType')
  },
  methods: {},
  mounted() {
    this.getmodelselect()
    this.grouplist()
    this.activeName = 'third'
    this.unitmerchantpage()
  },
  computed: {
    documentClientHeight: {
      get() {
        return this.$store.state.common.documentClientHeight
      }
    }
  },
  computed: {
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },
  methods: {
    addtForm() {
      this.addDialogFormVisible = true
    },
    eidtDate(row) {
      this.eidtdataForm.templateName = row.templateName
      this.eidtdataForm.templateGuid = row.templateGuid
      this.eidtDialogFormVisible = true
    },
    resetDate(row) {
      console.log(row)
      this.resetdataForm.templateGuid = row.templateGuid
      this.resetDialogFormVisible = true
    },
    addvisible() {
      this.addDialogFormVisible = false
      this.$refs['adddataForm'].resetFields()
    },
    eidtvisible() {
      this.eidtDialogFormVisible = false
      this.$refs['eidtdataForm'].resetFields()
    },
    resetvisible() {
      this.resetDialogFormVisible = false
      this.$refs['resetdataForm'].resetFields()
    },
    closeDialog(done) {
      this.$refs['adddataForm'].resetFields()
      done()
    },
    eidtcloseDialog(done) {
      this.$refs['eidtdataForm'].resetFields()
      done()
    },
    resetcloseDialog(done) {
      this.$refs['resetdataForm'].resetFields()
      done()
    },
    // 新增模板
    addFormSubmit() {
      this.$refs['adddataForm'].validate(valid => {
        if (valid) {
          console.log(this.adddataForm.templatePassword)
          if (
            this.adddataForm.templatePassword === '' ||
            this.adddataForm.templatePassword === null
          ) {
            var templatePassword = ''
          } else {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var templatePassword = encryptor.encrypt(
              this.$md5(this.adddataForm.templatePassword)
            )
          }
          this.$http({
            url: this.$http.adornUrl(
              '/terminal/consume/consume19-parameter-add'
            ),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                templateName: this.adddataForm.templateName,
                templatePassword: templatePassword,
                unitGuid: this.changeschoolid
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '新增成功',
                type: 'success'
              })
              this.getmodelselect()
              this.addDialogFormVisible = false
              this.$refs['adddataForm'].resetFields()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    eidtFormSubmit() {
      this.$refs['eidtdataForm'].validate(valid => {
        if (valid) {
          if (
            this.eidtdataForm.oldPassword === '' ||
            this.eidtdataForm.oldPassword === null
          ) {
            var oldPassword = ''
          }
          if (
            this.eidtdataForm.newPassword === '' ||
            this.eidtdataForm.newPassword === null
          ) {
            var newPassword = ''
          }
          if (
            this.eidtdataForm.oldPassword !== '' &&
            this.eidtdataForm.oldPassword !== null
          ) {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var oldPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.oldPassword)
            )
          }
          if (
            this.eidtdataForm.newPassword !== '' &&
            this.eidtdataForm.newPassword !== null
          ) {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var newPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.newPassword)
            )
          }
          if (this.changepassword == false) {
            newPassword = null
          }
          this.$http({
            url: this.$http.adornUrl('/terminal/template-update-password'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                newPassword: newPassword,
                oldPassword: oldPassword,
                unitGuid: this.changeschoolid,
                templateName: this.eidtdataForm.templateName,
                templateGuid: this.eidtdataForm.templateGuid,
                terminalType: 1
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '修改成功',
                type: 'success'
              })
              this.getmodelselect()
              this.eidtDialogFormVisible = false
              this.$refs['eidtdataForm'].resetFields()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    resetFormSubmit() {
      this.$refs['resetdataForm'].validate(valid => {
        if (valid) {
          let encryptor = new JSEncrypt()
          encryptor.setPublicKey(this.publicKey)
          let confirmtemplatePassword = encryptor.encrypt(
            this.$md5(this.resetdataForm.confirmtemplatePassword)
          )
          this.$http({
            url: this.$http.adornUrl('/terminal/template-reset-password'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                templatePassword: confirmtemplatePassword,
                templateGuid: this.resetdataForm.templateGuid,
                unitGuid: this.changeschoolid,
                operatorGuid: this.operatorGuid
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '重置成功',
                type: 'success'
              })
              this.getmodelselect()
              this.resetDialogFormVisible = false
              this.$refs['resetdataForm'].resetFields()
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    //获取房间模板参数列
    getmodelselect() {
      this.$http({
        url: this.$http.adornUrl('/terminal/template-model-select'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            terminalType: 1,
            unitGuid: this.changeschoolid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data)
          this.tableData = data.messageContent
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    deleteDate(row) {
      this.$prompt('请输入密码,无则不输入', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(({ value }) => {
          if (value !== null && value !== '') {
            let templatePassword = value
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            templatePassword = encryptor.encrypt(this.$md5(templatePassword))
            this.deletconsumptiondata(row, templatePassword)
          } else {
            let templatePassword = ''
            this.deletconsumptiondata(row, templatePassword)
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          })
        })
    },
    //导出
    onExport() {
      if (this.temeplatecheck === false) {
        this.$message({
          message: '请选择模板再导出',
          type: 'warning'
        })
        return
      }
      this.outexecel()
    },
    outexecel() {
      setTimeout(() => {
        this.export2Excel()
      }, 100)
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        })
      )
    },
    export2Excel() {
      const nowtime = this.getimeto()
      require.ensure([], () => {
        let multiHeader = [
          [
            '启用规则',
            '消费角色',
            '消费规则类型',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            '汇总限制',
            '',
            '',
            ''
          ]
        ]
        let multiHeader2 = [
          [
            '',
            '',
            '限制类型',
            '早餐',
            '',
            '',
            '中餐',
            '',
            '',
            '晚餐',
            '',
            '',
            '夜宵',
            '',
            '',
            '日周月限制规则',
            '',
            '时段规则分组',
            '启用限制',
            '限制金额(分)',
            '限制次数',
            '汇总规则分组'
          ]
        ]

        let merges = [
          'A1:A3',
          'B1:B3',
          'C1:R1',
          'S1:V1',
          'C2:C3',
          'D2:F2',
          'G2:I2',
          'J2:L2',
          'M2:O2',
          'P2:Q2',
          'R2:R3',
          'S2:S3',
          'T2:T3',
          'U2:U3',
          'V2:V3',
          // "W1:W3",
          // "X1:X3",
          'A19:V19',
          'A22:V22',
          'A23:A24',
          'B23:B24',
          'C23:D23',
          'E23:F23',
          'G23:H23',
          'I23:J23',
          'K23:L23',
          'A41:V41',
          'A42:C42',
          'D42:F42',
          'G42:I42',
          'J42:L42',
          'M42:O42',
          'A45:V45'
        ]
        let tHeader = [
          '启用消费规则',
          '消费角色',
          '限制类型',
          '启用限制',
          '限制金额(分)',
          '限制次数',
          '启用限制',
          '限制金额(分)',
          '限制次数',
          '启用限制',
          '限制金额(分)',
          '限制次数',
          '启用限制',
          '限制金额(分)',
          '限制次数',
          '限制金额(分)',
          '限制次数',
          '时段规则分组',
          '启用规则',
          // "限制周期",
          '限制金额(分)',
          '限制次数',
          '汇总规则分组'
        ]
        const { export_json_to_excel } = require('../../excel/Export2Excel')
        const filterVal = [
          'isOpenAll',
          'groupCode',
          'restrictionPeriod',
          'isOpen_morning',
          'restrictionAmount_morning',
          'restrictionNumber_morning',
          'isOpen_lunch',
          'restrictionAmount_lunch',
          'restrictionNumber_lunch',
          'isOpen_dinner',
          'restrictionAmount_dinner',
          'restrictionNumber_dinner',
          'isOpen_night',
          'restrictionAmount_night',
          'restrictionNumber_night',
          'restrictionAmount',
          'restrictionNumber',
          'cardStorageSiteAll',
          'isOpen_extra',
          // "restrictionPeriod_extra",
          'restrictionAmount_extra',
          'restrictionNumber_extra',
          'cardStorageSite_extra',
          'isOpenExcess',
          'creditCardSpaceTime'
        ]
        const list = this.exoprtlist
        const data = this.formatJson(filterVal, list)

        export_json_to_excel({
          multiHeader,
          multiHeader2, //这里是第二行的表头
          header: tHeader,
          data,
          merges,
          filename: this.filename + nowtime,
          tableheader: '2'
        })
      })
    },
    rowClick(row) {
      this.isShow = true
      this.temeplatecheck = true
      console.log(row)
      this.consumeparametersearch(row.templateGuid)
      this.templateGuid = row.templateGuid
    },
    //启用限制
    modificationtype(val) {
      if (val == false) {
        val = '否'
      } else {
        val = '是'
      }
      return val
    },
    //消费角色
    consumerrole(val, option) {
      for (var j = 0; j < option.length; j++) {
        if (val == option[j].value) {
          val = option[j].label
        }
      }
      return val
    },
    //查看消费机参数模板详情信息
    consumeparametersearch(templateGuid) {
      this.alldata = []
      this.exoprtlist = []
      this.loading = true
      this.$http({
        url: this.$http.adornUrl(
          '/terminal/consume/consume19-parameter-search'
        ),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            templateGuid:
              templateGuid == null || undefined
                ? this.templateGuid
                : templateGuid,
            unitGuid: this.changeschoolid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.alldata = data.messageContent
          this.elform.isOpenExcess = this.alldata.isOpenExcess
          this.elform.creditCardSpaceTime = this.alldata.creditCardSpaceTime
          this.rosterType = this.alldata.rosterType
          this.terminalOperationPassword = this.alldata.terminalOperationPassword
          this.manageNumber = this.alldata.manageNumber
          this.returnWaitInterfaceTime = this.alldata.returnWaitInterfaceTime
          this.consumeModel = this.alldata.consumeModel
          // 名单分区字节序号
          this.rosterDistrictByteOrder = this.alldata.rosterDistrictByteOrder
          /**无线空闲重启计时*/
          this.wirelessIdleRestartTiming = this.alldata.wirelessIdleRestartTiming
          this.cardTermValidityExamine =
            this.alldata.cardTermValidityExamine == 1 ? true : false
          this.autoAddCardPeriodValidity =
            this.alldata.autoAddCardPeriodValidity == 1 ? true : false
          this.cardType = this.alldata.cardType
          this.cardMaxConsumeAmountMoney = this.alldata.cardMaxConsumeAmountMoney
          this.cardMaxAmountMoney = this.alldata.cardMaxAmountMoney
          this.securityEndConsumeAmountMoney = this.alldata.securityEndConsumeAmountMoney
          this.creditCardTimeSpaceExamine = this.alldata.creditCardTimeSpaceExamine
          for (var i = 0; i < this.alldata.timeFrameDataList.length; i++) {
            if (parseInt(this.alldata.timeFrameDataList[i].endHour) < 10) {
              this.alldata.timeFrameDataList[i].endHour =
                '0' + this.alldata.timeFrameDataList[i].endHour
            }
            if (parseInt(this.alldata.timeFrameDataList[i].endMinute) < 10) {
              this.alldata.timeFrameDataList[i].endMinute =
                '0' + this.alldata.timeFrameDataList[i].endMinute
            }
            if (parseInt(this.alldata.timeFrameDataList[i].stateHour) < 10) {
              this.alldata.timeFrameDataList[i].stateHour =
                '0' + this.alldata.timeFrameDataList[i].stateHour
            }
            if (parseInt(this.alldata.timeFrameDataList[i].stateMinute) < 10) {
              this.alldata.timeFrameDataList[i].stateMinute =
                '0' + this.alldata.timeFrameDataList[i].stateMinute
            }

            this.$set(
              this.alldata.timeFrameDataList[i],
              'starttime',
              this.alldata.timeFrameDataList[i].stateHour.toString() +
                ':' +
                this.alldata.timeFrameDataList[i].stateMinute.toString()
            )
            this.$set(
              this.alldata.timeFrameDataList[i],
              'endTime',
              this.alldata.timeFrameDataList[i].endHour.toString() +
                ':' +
                this.alldata.timeFrameDataList[i].endMinute.toString()
            )
            // 是否自动开启
            this.$set(
              this.alldata.timeFrameDataList[i],
              'isAutoWithhold',
              this.alldata.timeFrameDataList[i].isAutoWithhold == 1
                ? true
                : false
            )
            console.log(this.alldata.timeFrameDataList[i].isAutoWithhold)
          }
          this.loading = false
          console.log(data.messageContent)
          //导出数据
          for (
            var i = 0;
            i < data.messageContent.groupRestrictionDataList.length;
            i++
          ) {
            let exoprtlistarr = []

            exoprtlistarr = JSON.parse(
              JSON.stringify(data.messageContent.groupRestrictionDataList[i])
            )
            exoprtlistarr.isOpenAll = this.modificationtype(
              exoprtlistarr.isOpenAll
            )
            exoprtlistarr.isOpen_morning = this.modificationtype(
              exoprtlistarr.isOpen_morning
            )
            exoprtlistarr.isOpen_lunch = this.modificationtype(
              exoprtlistarr.isOpen_lunch
            )
            exoprtlistarr.isOpen_dinner = this.modificationtype(
              exoprtlistarr.isOpen_dinner
            )
            exoprtlistarr.isOpen_night = this.modificationtype(
              exoprtlistarr.isOpen_night
            )
            exoprtlistarr.isOpen_extra = this.modificationtype(
              exoprtlistarr.isOpen_extra
            )
            exoprtlistarr.groupCode = this.consumerrole(
              exoprtlistarr.groupCode,
              this.grouplistdata
            )
            exoprtlistarr.restrictionPeriod = this.consumerrole(
              exoprtlistarr.restrictionPeriod,
              this.mealrestrictionsoption
            )
            this.exoprtlist.push(exoprtlistarr)
          }
          let exoprtlistarr2 = [
            {},
            {
              isOpenAll: '消费超出限制规则时',
              groupCode: '同一张卡刷卡时间间隔'
            },
            {
              isOpenAll: this.consumerrole(
                data.messageContent.isOpenExcess,
                this.isOpenExcessoption
              ),
              groupCode: data.messageContent.creditCardSpaceTime
            }
          ]
          this.exoprtlist = this.exoprtlist.concat(exoprtlistarr2)

          let exoprtlistarr3 = [
            {},
            {
              isOpenAll: '启用规则',
              groupCode: '消费角色',
              restrictionPeriod: '早餐',
              isOpen_morning: '',
              restrictionAmount_morning: '中餐',
              restrictionNumber_morning: '',
              isOpen_lunch: '晚餐',
              restrictionAmount_lunch: '',
              restrictionNumber_lunch: '夜宵',
              isOpen_dinner: '',
              restrictionAmount_dinner: '追加时段',
              restrictionNumber_dinner: '',
              isOpen_night: '',
              restrictionAmount_night: '',
              restrictionNumber_night: '',
              restrictionAmount: '',
              restrictionNumber: '',
              cardStorageSiteAll: '',
              isOpen_extra: '',
              // restrictionPeriod_extra:'',
              restrictionAmount_extra: '',
              restrictionNumber_extra: '',
              // cardStorageSite_extra: "",
              isOpenExcess: '',
              creditCardSpaceTime: ''
            },
            {
              isOpenAll: '',
              groupCode: '',
              restrictionPeriod: '是否启用',
              isOpen_morning: '定额金额2(分)',
              restrictionAmount_morning: '是否启用',
              restrictionNumber_morning: '定额金额2(分)',
              isOpen_lunch: '是否启用',
              restrictionAmount_lunch: '定额金额2(分)',
              restrictionNumber_lunch: '是否启用',
              isOpen_dinner: '定额金额2(分)',
              restrictionAmount_dinner: '是否启用',
              restrictionNumber_dinner: '定额金额2(分)',
              isOpen_night: '',
              restrictionAmount_night: '',
              restrictionNumber_night: '',
              restrictionAmount: '',
              restrictionNumber: '',
              cardStorageSiteAll: '',
              isOpen_extra: '',
              // restrictionPeriod_extra:'',
              restrictionAmount_extra: '',
              restrictionNumber_extra: '',
              // cardStorageSite_extra: "",
              isOpenExcess: '',
              creditCardSpaceTime: ''
            }
          ]
          this.exoprtlist = this.exoprtlist.concat(exoprtlistarr3)
          for (
            var i = 0;
            i < data.messageContent.groupAmountDataList.length;
            i++
          ) {
            let exoprtlistObj = {
              isOpenAll: this.modificationtype(
                JSON.stringify(
                  data.messageContent.groupAmountDataList[i]
                    .validSignAllvalidSignAll
                )
              ),
              groupCode: this.consumerrole(
                JSON.stringify(
                  data.messageContent.groupAmountDataList[i].groupCode
                ),
                this.grouplistdata
              ),
              restrictionPeriod: JSON.stringify(
                data.messageContent.groupAmountDataList[i].validSignMorning
              ),
              isOpen_morning: JSON.stringify(
                data.messageContent.groupAmountDataList[i].groupAmount_morning
              ),
              restrictionAmount_morning: JSON.stringify(
                data.messageContent.groupAmountDataList[i].validSignLunch
              ),
              restrictionNumber_morning: JSON.stringify(
                data.messageContent.groupAmountDataList[i].groupAmount_lunch
              ),
              isOpen_lunch: JSON.stringify(
                data.messageContent.groupAmountDataList[i].validSignDinner
              ),
              restrictionAmount_lunch: JSON.stringify(
                data.messageContent.groupAmountDataList[i].groupAmount_dinner
              ),
              restrictionNumber_lunch: JSON.stringify(
                data.messageContent.groupAmountDataList[i].validSignNight
              ),
              isOpen_dinner: JSON.stringify(
                data.messageContent.groupAmountDataList[i].groupAmount_night
              ),
              restrictionAmount_dinner: JSON.stringify(
                data.messageContent.groupAmountDataList[i].validSignExtra
              ),
              restrictionNumber_dinner: JSON.stringify(
                data.messageContent.groupAmountDataList[i].groupAmount_extra
              ),
              isOpen_night: '',
              restrictionAmount_night: '',
              restrictionNumber_night: '',
              restrictionAmount: '',
              restrictionNumber: '',
              cardStorageSiteAll: '',
              isOpen_extra: '',
              //  restrictionPeriod_extra:'',
              restrictionAmount_extra: '',
              restrictionNumber_extra: '',
              // cardStorageSite_extra: "",
              isOpenExcess: '',
              creditCardSpaceTime: ''
            }
            this.exoprtlist.push(exoprtlistObj)
          }
          // let [...alldatalist] = this.alldata
          //      rosterType: "",
          // terminalOperationPassword: "",
          // manageNumber: "",
          // returnWaitInterfaceTime: "",
          // consumeModel: "",
          // cardTermValidityExamine: false,
          // autoAddCardPeriodValidity: false,
          // cardType: "",
          // cardMaxConsumeAmountMoney: "",
          // cardMaxAmountMoney: "",
          // securityEndConsumeAmountMoney: "",
          let exoprtlistarr4 = [
            {},
            {
              isOpenAll: '早餐',
              groupCode: '',
              restrictionPeriod: '',
              isOpen_morning: '中餐',
              restrictionAmount_morning: '',
              restrictionNumber_morning: '',
              isOpen_lunch: '晚餐',
              restrictionAmount_lunch: '',
              restrictionNumber_lunch: '',
              isOpen_dinner: '夜宵',
              restrictionAmount_dinner: '',
              restrictionNumber_dinner: '',
              isOpen_night: '追加时段',
              restrictionAmount_night: '',
              restrictionNumber_night: ''
            },
            {
              isOpenAll: '是否开启',
              groupCode: '开始时间',
              restrictionPeriod: '结束时间',
              isOpen_morning: '是否开启',
              restrictionAmount_morning: '开始时间',
              restrictionNumber_morning: '结束时间',
              isOpen_lunch: '是否开启',
              restrictionAmount_lunch: '开始时间',
              restrictionNumber_lunch: '结束时间',
              isOpen_dinner: '是否开启',
              restrictionAmount_dinner: '开始时间',
              restrictionNumber_dinner: '结束时间',
              isOpen_night: '是否开启',
              restrictionAmount_night: '开始时间',
              restrictionNumber_night: '结束时间'
            },
            {
              isOpenAll: this.modificationtype(
                this.alldata.timeFrameDataList[0].validSign
              ),
              groupCode: this.alldata.timeFrameDataList[0].starttime,
              restrictionPeriod: this.alldata.timeFrameDataList[0].endTime,
              isOpen_morning: this.modificationtype(
                this.alldata.timeFrameDataList[1].validSign
              ),
              restrictionAmount_morning: this.alldata.timeFrameDataList[1]
                .starttime,
              restrictionNumber_morning: this.alldata.timeFrameDataList[1]
                .endTime,
              isOpen_lunch: this.modificationtype(
                this.alldata.timeFrameDataList[2].validSign
              ),
              restrictionAmount_lunch: this.alldata.timeFrameDataList[2]
                .starttime,
              restrictionNumber_lunch: this.alldata.timeFrameDataList[2]
                .endTime,
              isOpen_dinner: this.modificationtype(
                this.alldata.timeFrameDataList[3].validSign
              ),
              restrictionAmount_dinner: this.alldata.timeFrameDataList[3]
                .starttime,
              restrictionNumber_dinner: this.alldata.timeFrameDataList[3]
                .endTime,
              isOpen_night: this.modificationtype(
                this.alldata.timeFrameDataList[4].validSign
              ),
              restrictionAmount_night: this.alldata.timeFrameDataList[4]
                .starttime,
              restrictionNumber_night: this.alldata.timeFrameDataList[4]
                .endTime,
              restrictionAmount: '',
              restrictionNumber: '',
              cardStorageSiteAll: '',
              isOpen_extra: '',
              restrictionAmount_extra: ''
            }
          ]
          this.exoprtlist = this.exoprtlist.concat(exoprtlistarr4)
          let exoprtlistarr5 = [
            {},
            {
              isOpenAll: '名单类型',
              groupCode: '设备配置密码/退款',
              restrictionPeriod: '管理卡号',
              isOpen_morning: '返回待机界面时间',
              restrictionAmount_morning: '消费模式',
              restrictionNumber_morning: '启用卡有效时间',
              isOpen_lunch: '刷卡自动延长有效期',
              restrictionAmount_lunch: '使用卡类型',
              restrictionNumber_lunch: '最大当次消费额(分)',
              isOpen_dinner: '允许卡内最大金额(分)',
              restrictionAmount_dinner: '允许卡内最少金额(分)'
            },
            {
              isOpenAll: this.rosterType === 0 ? '黑名单' : '白名单',
              groupCode: this.terminalOperationPassword,
              restrictionPeriod: this.manageNumber,
              isOpen_morning: this.returnWaitInterfaceTime,
              restrictionAmount_morning: this.consumerrole(
                this.consumeModel,
                this.consumeModeloption
              ),
              restrictionNumber_morning:
                this.cardTermValidityExamine == true ? '是' : '否',
              isOpen_lunch:
                this.autoAddCardPeriodValidity == true ? '是' : '否',
              restrictionAmount_lunch: this.consumerrole(
                this.cardType,
                this.cardTypeoption
              ),
              restrictionNumber_lunch: this.cardMaxConsumeAmountMoney,
              isOpen_dinner: this.cardMaxAmountMoney,
              restrictionAmount_dinner: this.securityEndConsumeAmountMoney,
              creditCardTimeSpaceExamine: this.creditCardTimeSpaceExamine
            }
          ]
          console.log(this.exoprtlist)
          this.exoprtlist = this.exoprtlist.concat(exoprtlistarr5)
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    selectime() {
      // alert('123141')
      console.log(this.alldata)
    },
    //分组查询
    grouplist() {
      this.grouplistdata = []
      this.$http({
        url: this.$http.adornUrl('/unit/unit-user-group-list'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: this.changeschoolid,
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          for (var i = 0; i < data.messageContent.length; i++) {
            let itemobj = {
              label: data.messageContent[i].groupName,
              value: data.messageContent[i].groupCode
            }
            this.grouplistdata.push(itemobj)
          }
          console.log(this.grouplistdata)
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },

    //规则分组
    selectcardsiteall(row, index) {
      if (
        this.alldata.groupRestrictionDataList[index].cardStorageSiteAll ==
        this.alldata.groupRestrictionDataList[index].cardStorageSite_extra
      ) {
        this.$message({
          message: '时段规则分组与汇总规则分组冲突',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].cardStorageSiteAll = ''
      }
    },
    //汇总规则分组
    selectextraSite(row, index) {
      if (
        this.alldata.groupRestrictionDataList[index].cardStorageSiteAll ==
        this.alldata.groupRestrictionDataList[index].cardStorageSite_extra
      ) {
        this.$message({
          message: '汇总规则分组冲突与时段规则分组',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].cardStorageSite_extra = ''
      }
    },
    restrictionPeriod(val) {
      console.log(val)
    },
    //获金额限制判断
    getmoneyAmount(val, index) {
      if (val < 0 || val > 650 * 100 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionAmount = 0
      }
    },
    getmoneymorning(val, index) {
      if (val < 0 || val > 650 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[
          index
        ].restrictionAmount_morning = 0
      }
    },
    getmoneylunch(val, index) {
      if (val < 0 || val > 650 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionAmount_lunch = 0
      }
    },
    getmoneydinner(val, index) {
      if (val < 0 || val > 650 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[
          index
        ].restrictionAmount_dinner = 0
      }
    },
    getmoneynight(val, index) {
      if (val < 0 || val > 650 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionAmount_night = 0
      }
    },
    getmoneyextra(val, index) {
      if (val < 0 || val > 650 * 100) {
        this.$message({
          message: '金额数据格式不正确范围在0~65000',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionAmount_extra = 0
      }
    },
    //次数限制判断
    getnumberlimtNumbe(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionNumber = 0
      }
    },
    getnumberlimtmorning(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[
          index
        ].restrictionNumber_morning = 0
      }
    },
    getnumberlimtlunch(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionNumber_lunch = 0
      }
    },
    getnumberlimtdinner(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[
          index
        ].restrictionNumber_dinner = 0
      }
    },
    getnumberlimtnight(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionNumber_night = 0
      }
    },
    getnumberlimtextra(val, index) {
      let reg = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/
      if (reg.test(val)) {
        return true
      } else {
        this.$message({
          message: '限制次数据格式不正确范围在0~250',
          type: 'warning'
        })
        this.alldata.groupRestrictionDataList[index].restrictionNumber_extra = 0
      }
    },
    changetime() {
      console.log(this.timevalue1)
      console.log(this.timevalue1[0].split(':')[0])
      console.log(this.timevalue1[0].split(':')[1])
    },
    checkusing() {
      console.log(this.timeFrameDataList)
    },
    savealldata() {
      if (this.temeplatecheck === false) {
        this.$message({
          message: '请选择模板保存',
          type: 'warning'
        })
        return
      }
      this.alldata.isOpenExcess = this.elform.isOpenExcess
      this.alldata.creditCardSpaceTime = parseInt(
        this.elform.creditCardSpaceTime
      )
      for (var i = 0; i < this.alldata.timeFrameDataList.length; i++) {
        console.log(this.alldata.timeFrameDataList[i].starttime)
        console.log(this.alldata.timeFrameDataList[i].starttime.split(':')[0])
        this.alldata.timeFrameDataList[
          i
        ].stateHour = this.alldata.timeFrameDataList[i].starttime.split(':')[0]
        this.alldata.timeFrameDataList[
          i
        ].stateMinute = this.alldata.timeFrameDataList[i].starttime.split(
          ':'
        )[1]
        this.alldata.timeFrameDataList[
          i
        ].endHour = this.alldata.timeFrameDataList[i].endTime.split(':')[0]
        this.alldata.timeFrameDataList[
          i
        ].endMinute = this.alldata.timeFrameDataList[i].endTime.split(':')[1]
        // 是否自动开启
        this.alldata.timeFrameDataList[i].isAutoWithhold = this.alldata
          .timeFrameDataList[i].isAutoWithhold
          ? 1
          : 0
      }
      console.log(this.alldata.timeFrameDataList)
      for (var i = 0; i < this.alldata.timeFrameDataList.length; i++) {
        if (this.alldata.timeFrameDataList[i].stateHour == '00') {
          this.alldata.timeFrameDataList[i].stateHour = 0
          console.log(this.alldata.timeFrameDataList[i].stateHour)
        }
        if (
          this.alldata.timeFrameDataList[i].stateHour < 10 &&
          this.alldata.timeFrameDataList[i].stateHour != 0
        ) {
          // console.log(parseInt(this.alldata.timeFrameDataList[i].stateHour.substr(1)))
          console.log(this.alldata.timeFrameDataList[i].stateHour)
          this.alldata.timeFrameDataList[i].stateHour = parseInt(
            this.alldata.timeFrameDataList[i].stateHour.substr(1)
          )
        } else {
          this.alldata.timeFrameDataList[i].stateHour = parseInt(
            this.alldata.timeFrameDataList[i].stateHour
          )
        }

        if (this.alldata.timeFrameDataList[i].stateMinute === '00') {
          this.alldata.timeFrameDataList[i].stateMinute = 0
        }
        if (
          this.alldata.timeFrameDataList[i].stateMinute < 10 &&
          this.alldata.timeFrameDataList[i].stateMinute != 0
        ) {
          this.alldata.timeFrameDataList[i].stateMinute = parseInt(
            this.alldata.timeFrameDataList[i].stateMinute.substr(1)
          )
        } else {
          this.alldata.timeFrameDataList[i].stateMinute = parseInt(
            this.alldata.timeFrameDataList[i].stateMinute
          )
        }

        if (this.alldata.timeFrameDataList[i].endHour === '00') {
          this.alldata.timeFrameDataList[i].endHour = 0
        }
        if (
          this.alldata.timeFrameDataList[i].endHour < 10 &&
          this.alldata.timeFrameDataList[i].endHour != 0
        ) {
          this.alldata.timeFrameDataList[i].endHour = parseInt(
            this.alldata.timeFrameDataList[i].endHour.substr(1)
          )
        } else {
          this.alldata.timeFrameDataList[i].endHour = parseInt(
            this.alldata.timeFrameDataList[i].endHour
          )
        }

        if (this.alldata.timeFrameDataList[i].endMinute === '00') {
          this.alldata.timeFrameDataList[i].endMinute = 0
        }
        if (
          this.alldata.timeFrameDataList[i].endMinute < 10 &&
          this.alldata.timeFrameDataList[i].endMinute != 0
        ) {
          this.alldata.timeFrameDataList[i].endMinute = parseInt(
            this.alldata.timeFrameDataList[i].endMinute.substr(1)
          )
        } else {
          this.alldata.timeFrameDataList[i].endMinute = parseInt(
            this.alldata.timeFrameDataList[i].endMinute
          )
        }
      }

      this.alldata.rosterType = parseInt(this.rosterType)
      this.alldata.terminalOperationPassword = parseInt(
        this.terminalOperationPassword
      )
      this.alldata.manageNumber = parseInt(this.manageNumber) || 0
      if(this.alldata.manageNumber < 0 ||this.alldata.manageNumber >  4294967295){
         this.$message({
            message:'管理卡号范围是0-4294967295',
            type: 'error'
          })
          return ;
      }
      this.alldata.returnWaitInterfaceTime = parseInt(
        this.returnWaitInterfaceTime
      )
      this.alldata.consumeModel = parseInt(this.consumeModel)
      // 名单分区字节序号
      this.alldata.rosterDistrictByteOrder = this.rosterDistrictByteOrder
      /**无线空闲重启计时*/
      this.alldata.wirelessIdleRestartTiming = this.wirelessIdleRestartTiming
      this.alldata.cardTermValidityExamine =
        this.cardTermValidityExamine == false ? 0 : 1
      this.alldata.autoAddCardPeriodValidity =
        this.autoAddCardPeriodValidity == false ? 0 : 1
      this.alldata.cardType = this.cardType
      this.alldata.cardMaxConsumeAmountMoney = this.cardMaxConsumeAmountMoney
      this.alldata.cardMaxAmountMoney = this.cardMaxAmountMoney
      this.alldata.securityEndConsumeAmountMoney = this.securityEndConsumeAmountMoney
      this.alldata.creditCardTimeSpaceExamine = this.creditCardTimeSpaceExamine
      if (
        this.alldatatemplatePassword !== '' &&
        this.alldatatemplatePassword !== null
      ) {
        var templatePassword1 = this.alldatatemplatePassword
        let encryptor = new JSEncrypt()
        encryptor.setPublicKey(this.publicKey)
        templatePassword1 = encryptor.encrypt(this.$md5(templatePassword1))
      }

      this.consumeparameterupdate(this.alldata, templatePassword1)
    },
    // 更新消费参数模板信息
    consumeparameterupdate(alldata, templatePassword1) {
      this.$http({
        url: this.$http.adornUrl(
          '/terminal/consume/consume19-parameter-update'
        ),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            parameterData: alldata,
            unitGuid: this.changeschoolid,
            templateGuid: this.templateGuid,
            templatePassword: templatePassword1
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.consumeparametersearch()
          this.$message({
            message: '更新成功',
            type: 'success'
          })
        } else {
          this.consumeparametersearch()
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    //删除模板数据
    deletconsumptiondata(row, templatePassword) {
      this.$http({
        url: this.$http.adornUrl('/terminal/consume/consume-parameter-delete'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            templateGuid: row.templateGuid,
            unitGuid: this.changeschoolid,
            templatePassword: templatePassword
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          this.getmodelselect()
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //卡片切换
    handleClick() {
      // console.log(this.)
    },
    //结算单位
    unitmerchantpage() {
      this.settlementunitoption = []
      this.searchInfo.unitGuid = this.changeschoolid
      this.$http({
        url: this.$http.adornUrl('/terminal/merchant/unit-merchant-page'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            pageNum: 1,
            pageSize: 999999,
            searchInfo: this.searchInfo
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data)
          for (var i = 0; i < data.messageContent.data.length; i++) {
            let itemobj = {
              label: data.messageContent.data[i].merchantName,
              value: data.messageContent.data[i].merchantGuid
            }
            this.settlementunitoption.push(itemobj)
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //参数应用
    applicationparameters() {
      if (this.settlementunitGuid == null || this.settlementunitGuid == '') {
        this.$message({
          type: 'warning',
          message: '请选择应用商户!'
        })
        return
      }
      if (this.templateGuid == null || this.templateGuid == '') {
        this.$message({
          type: 'warning',
          message: '请选择参数模板!'
        })
        return
      }
      this.$http({
        url: this.$http.adornUrl(
          '/terminal/consume/consume-parameter-build-merchant'
        ),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            merchantGuid: this.settlementunitGuid,
            templateGuid: this.templateGuid,
            unitGuid: this.changeschoolid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '应用成功!'
          })
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //重新下发该商户设备
    savemerchant() {
      // if (this.settlementunitGuid == null || this.settlementunitGuid == "") {
      //   this.$message({
      //     type: "warning",
      //     message: "请选择应用商户!",
      //   });
      //   return;
      // }
      if (this.templateGuid == null || this.templateGuid == '') {
        this.$message({
          type: 'warning',
          message: '请选择参数模板!'
        })
        return
      }
      this.$confirm('是否重发该模板的参数?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl('/terminal/reset-template'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                // merchantGuid: this.settlementunitGuid,
                templateGuid: this.templateGuid,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                type: 'success',
                message: '下发成功!'
              })
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    }
    //
  }
}
</script>

<style lang="scss" scoped>
.consumer_machine {
  /deep/.el-tabs--border-card > .el-tabs__content {
    // padding-left: 10px;
  }
  /deep/.el-table {
    /deep/tbody tr:hover > td {
      cursor: pointer;
    }
  }
  // height: 600px;
  // padding: 20px;
  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 20px;
  }

  //滚动条的宽度
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  //滚动条的滑块
  ::-webkit-scrollbar-thumb {
    background-color: #a1a3a9;
    border-radius: 3px;
  }

  .el-row {
    // height: 100%;
    // margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }

    .grid-content {
      // min-height: 600px;
      .header_title,
      .addtemplate {
        padding: 20px 0;
        font-weight: bolder;
        padding-left: 20px;
        border-bottom: 1px solid #e5e9f2;
        color: #909399;
        text-align: center;
        overflow: hidden;
      }
      .addtemplate {
        padding: 5px 0;
      }
    }

    .bg-purple {
      // height: 100%;
      // background: #d3dce6;
      height: auto;
    }

    .bg-purple-light {
      padding: 0px;
      padding-top: 40px;
      .explanation .el-table th,
      .hostForm .el-table tr {
        font-weight: normal;
      }
      .demo-form-inline,
      .demo-form-inline1 {
        padding-bottom: 5px;
        display: flex;

        /deep/.el-form-item__label {
          padding-right: 5px;
        }

        .el-radio + .el-radio {
          margin-right: 0px;
        }

        .el-form-item {
          margin-bottom: 0px;
        }

        .el-date-editor.el-input,
        .el-date-editor.el-input__inner {
          width: 100%;
        }

        .el-row {
          width: 100%;
        }

        .shi_jian_zhi,
        .xuan_zhe,
        .danxuan {
          display: flex;
          justify-content: center;
        }
      }

      .demo-form-inline1 {
        border-bottom: 1px solid #e5e9f2;

        .searchmarigin {
          margin-left: 20px;
        }
      }

      .consumption_rules {
        padding: 0;
        .el-form.demo-form-inline.el-form--inline {
          padding-bottom: 0;
          padding: 5px;
        }
      }

      .footer {
        height: 60px;
        display: flex;
        align-items: center;

        .el-card.is-always-shadow,
        .el-card.is-hover-shadow:focus,
        .el-card.is-hover-shadow:hover {
          width: 100%;
          height: 80%;
        }
      }
    }
  }
}
</style>
